//! config_manager.rs 单元测试
//! 
//! 测试配置管理器的策略模式实现

use redis_rs2::server::config_manager::*;
use redis_rs2::server::enhanced_traits::*;
use tokio_test;

#[cfg(test)]
mod config_manager_tests {
    use super::*;
    
    #[test]
    fn test_config_manager_creation() {
        let manager = ConfigManager::new();
        
        assert_eq!(manager.source_info().len(), 0);
        assert!(manager.current_config().is_none());
    }
    
    #[test]
    fn test_config_format_detection() {
        let toml_source = FileConfigSource::auto("config.toml".to_string());
        assert_eq!(toml_source.source_name(), "FileConfigSource");
        
        let json_source = FileConfigSource::auto("config.json".to_string());
        assert_eq!(json_source.source_name(), "FileConfigSource");
    }
    
    #[test]
    fn test_env_config_source() {
        let env_source = EnvConfigSource::redis_rs2();
        assert_eq!(env_source.source_name(), "EnvConfigSource");
        
        let source_info = env_source.source_info();
        assert_eq!(source_info.source_type, "Environment");
    }
    
    #[test]
    fn test_cli_config_source() {
        let args = vec![
            "program".to_string(),
            "--bind".to_string(),
            "127.0.0.1:8080".to_string(),
            "--mode".to_string(),
            "standalone".to_string(),
        ];
        
        let cli_source = CliConfigSource::new(args);
        assert_eq!(cli_source.source_name(), "CliConfigSource");
    }
    
    #[test]
    fn test_standard_config_manager() {
        let manager = create_standard_config_manager();
        let source_info = manager.source_info();
        
        // 应该有CLI和环境变量配置源
        assert!(!source_info.is_empty());
    }
}